<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ include file="Logined.jsp" %>
<jsp:useBean id="db" class="connBean.ConnDB" scope="page">
</jsp:useBean>
<link href="images/skin.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html;" />
<style type="text/css">
<!--
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
table tr{
height:40px;
line-height:40px
}

.tab_content{
border-bottom:1px dashed #cccccc;
border-right:1px dashed #cccccc;
}
.tab_title{
color:#444444;
font-size:20px;
font-weight:bold;
text-align:center;
}
</style>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">修改订单</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>
  <%    
  int order_id=Integer.parseInt(request.getParameter("selectid"));
  db.OpenConn();
  db.createStmt(); 
  String sql="SELECT a.order_id,a.pay_id,a.order_address,a.order_email,a.c_id,a.order_time,a.order_sum,a.order_status,b.pay_payment,c.c_name FROM orders as a left join payment as b on a.pay_id=b.pay_id left join Customer as c on a.c_id=c.c_id where a.order_id="+order_id;
  System.out.println(sql);
  ResultSet rs=db.Query(sql);
  
int pay_id=0;
  if(rs.next()){
  pay_id=rs.getInt("pay_id");
  
  
 %>
<form action="saveUpdateorder.jsp" method="post" ">

<table >


<tr>
<td class="tab_title">订单ID</td><td ><input type="text" name="order_id" value="<%=rs.getInt("order_id")%>" readonly/></td>
</tr>



<tr>
<td class="tab_title">订购者</td><td><input type="text" name="c_name" value="<%=rs.getString("c_name")%>" readonly/>

</td>
</tr>

<tr>
<td class="tab_title">地址</td><td><input type="text" name="order_address" value="<%=rs.getString("order_address")%>"/></td>
</tr>

<tr>
<td class="tab_title">邮箱</td><td><input type="text" name="order_email" value="<%=rs.getString("order_email")%>"/></td>
</tr>

<tr>
<td class="tab_title">订购时间</td><td><input type="text" name="order_time" value="<%=rs.getString("order_time")%>"/></td>
</tr>


<tr>
<td class="tab_title">订单状态</td>
<td><select name="order_status" >
<%

String a[]={"取消单","已提交订单","已支付订单","已发货"}; 
int b=rs.getInt("order_status");
int f;
for(f=0;f<4;f++){
String ztm=a[f];
if(a[f]==a[b]){%>
<option value="<%=f%>" selected> <%=ztm %> </option>
<% }else{%>

 <option value="<%=f%>"> <%=ztm %> </option>
<%} }%>			
			
</select></td>
</tr>

<tr>
<td class="tab_title">支付方式</td>
<td>

<select name="pay_id" >
<%
				String sql2 = "select * from payment";//定义查询SQL语句
				System.out.print(sql2);
				ResultSet mtrs = db.Query(sql2);//执行SQL语句
				while (mtrs.next()) {
				int pay_id2=mtrs.getInt("pay_id");
				String  pay_payment=mtrs.getString(2);
				
				if(pay_id2==pay_id){
			    %>
                 <option value="<%=pay_id2%>" selected> <%=pay_payment %> </option>
                <%}else{
                 %><option value="<%=pay_id2%>" > <%=pay_payment %> </option>
                 <%} 
                 }%>

 
</select>


</td>

</tr>


<tr>
<td class="tab_title" colspan=2> 
 <INPUT TYPE="submit" value=" 保存 ">  
<%String ref = request.getHeader("REFERER");%> 

<input type="button" name="returngo" value="返回"   onclick="javascript:window.location='<%=ref%>'" > 
</td>
</tr>

</table>
<%} %>
</form>



</td>
</tr>
      
    </table></td>
  </tr>

</table>
</body>

